package ${convertPackage};
import ${dtoPackage}.${entityNameNoPrefix}DTO;
import ${entityPackage}.${entityName};

import java.util.List;
import java.util.stream.Collectors;


/**
 * 类${entityName}Convert.java的实现描述：${tableDescription}
 * 
 * @author ${author} ${createTime}
 */
public class ${entityName}Convert {

    public static ${entityName} dto2model(${entityNameNoPrefix}DTO ${entityNameNoPrefix?uncap_first}DTO) {
        ${entityName} ${entityName?uncap_first} = new ${entityName}();
        <#list filterEntityColumns as col>
        ${entityName?uncap_first}.set${col.fieldName?cap_first}(${entityNameNoPrefix?uncap_first}DTO.get${col.fieldName?cap_first}());
        </#list>
        return  ${entityName?uncap_first};
    }

    public static ${entityNameNoPrefix}DTO model2dto(${entityName} ${entityName?uncap_first}) {
        ${entityNameNoPrefix}DTO ${entityNameNoPrefix?uncap_first}DTO = new ${entityNameNoPrefix}DTO();
        <#list filterEntityColumns as col>
		${entityNameNoPrefix?uncap_first}DTO.set${col.fieldName?cap_first}(${entityName?uncap_first}.get${col.fieldName?cap_first}());
        </#list>
        return  ${entityNameNoPrefix?uncap_first}DTO;
    }

    public static List<${entityName}> listDto2model(List<${entityNameNoPrefix}DTO> ${entityName?uncap_first}DtoList) {
        return ${entityName?uncap_first}DtoList.stream().map(p -> dto2model(p)).collect(Collectors.toList());
    }

    public static List<${entityNameNoPrefix}DTO> listModel2dto(List<${entityName}> ${entityName?uncap_first}List) {
        return ${entityName?uncap_first}List.stream().map(p -> model2dto(p)).collect(Collectors.toList());
    }
}
